package com.example.pertecttime.myview;

import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.example.pertecttime.R;

/**
 * Created by 半生瓜 on 2017/7/24.
 */

public class Titleview extends FrameLayout {
    private Button  lifeButtuo;
    private TextView titleText;

    public Titleview(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.titleview,this);
        titleText=(TextView)findViewById(R.id.title_text);
        lifeButtuo=(Button)findViewById(R.id.button_left) ;
        lifeButtuo.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                ((Activity)getContext()).finish();
            }
        });
    }
     public  void setTitleText(String text){
         titleText.setText(text);
     }
    public void setLifeButtuo(String text){
        lifeButtuo.setText(text);
    }
    public  void setLifeButtuo(OnClickListener l){
        lifeButtuo.setOnClickListener(l);
    }
}
